package com.trip.driver.controller;



import com.trip.common.dto.DriverOrderSearchDto;
import com.trip.common.dto.LoginDto;
import com.trip.common.dto.UpdateDriverDto;
import com.trip.common.entity.Driver;
import com.trip.common.entity.DriverScore;
import com.trip.common.entity.TravelStatus;
import com.trip.common.vo.Result;
import com.trip.driver.service.TravelStatusService;
import com.trip.driver.service.impl.DriverServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hr
 * @since 2024-09-05
 */
@RestController
@RequestMapping("/driver")
public class DriverController {

    @Autowired
    private DriverServiceImpl driverService;
    @Autowired
    private TravelStatusService travelStatusService;

    @RequestMapping("/loginByAccount")
    public Result loginByAccount(@RequestBody LoginDto loginDto){
        return driverService.loginByAccount(loginDto);
    }

    @RequestMapping("/loginByEmail")
    public Result loginByEmail(@RequestBody LoginDto loginDto){
        return driverService.loginByEmail(loginDto);
    }

    @RequestMapping("/sendEmail")
    public void sendEmail(@RequestBody String email){
        driverService.sendEmail(email);
    }

    @PostMapping("/updateDriverOrderStatus")
    public Result updateDriverOrderStatus(@RequestBody TravelStatus travelStatus){
        return travelStatusService.updateDriverOrderStatus(travelStatus);
    }

    @PostMapping("/updateDriverScore")
    public Result updateDriverScore(@RequestBody DriverScore driverScore){
        return travelStatusService.updateDriverScore(driverScore);
    }

    @RequestMapping("/getMyMoney")
    public BigDecimal getMyMoney(@RequestBody String token){
        return driverService.getMyMoney(token);
    }

    @RequestMapping("/getMyDistance")
    public String getMyDistance(@RequestBody String token){
        return driverService.getMyDistance(token);
    }

    @RequestMapping("/getMyOrderNum")
    public String getMyOrderNum(@RequestBody String token){
        return driverService.getMyOrderNum(token);
    }

    @RequestMapping("/getToDayPrice")
    public String getToDayPrice(@RequestBody String token){
        return driverService.getToDayPrice(token);
    }

    @RequestMapping("/getMyOrderDetail")
    public Result getMyOrderDetail(@RequestBody DriverOrderSearchDto driverOrderSearchDto){
        return driverService.getMyOrderDetail(driverOrderSearchDto);
    }

    @RequestMapping("/getOrderDetailByID")
    public Result getOrderDetailByID(@RequestBody String order_id){
        return driverService.getOrderDetailByID(order_id);
    }

    @RequestMapping("/getDriverInfo")
    public Result getDriverInfo(@RequestBody String token){
        return driverService.getDriverInfo(token);
    }

    @RequestMapping("/unpaidOrders")
    public Result unpaidOrders(@RequestBody String order_id){return driverService.unpaidOrders(order_id);}

    @RequestMapping("/getCommentByID")
    public Result getCommentByID(@RequestBody String token){
        return driverService.getCommentByID(token);
    }

    @RequestMapping("/updateDriverInfo")
    Result updateDriverInfo(@RequestBody UpdateDriverDto updateDriverDto){
        return driverService.updateDriverInfo(updateDriverDto);
    }

    @RequestMapping("/resetPWD")
    Result resetPWD(@RequestBody UpdateDriverDto updateDriverDto){
        return driverService.resetPWD(updateDriverDto);
    }

    @RequestMapping("/test")
    public String test(){return "测试";}
}

